<template>
  <div id="js-search-page" style="" class="search-container-wrap" v-if="isActive">
    <div class="js-header-wrap">
      <form class="search-wrap">
        <div class="search-box">
            <input type="text" v-model="searchKeyword" ref="searchKeyword" placeholder="搜索商铺或写字楼" id="js-search-keyword-text" autocomplete="off" autofocus>
            <span class="i-clear" id="search_button_gs_clear" @click="clear"></span>
        </div>
        <span class="s-back" id="search_button_gs_back" @click="back"></span>
        <button class="s-btn" type="submit" id="search_button_gs_global" @click="searchRes">搜索</button>
      </form>
    </div>
    <div class="js-index-wrap" id="js-search-result-div" style="display: block;">
      <div class="js-hot-wrap">
        <h4 class="search-title">热门搜索</h4>
        <ul class="search-list">
          <li v-for="(item,index) in hots" :key="index" @click="_hotHref(item)" :keyword="item.name">{{item.name}}<i class="fill-in" @click="_fillWord(item)"></i></li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default({
  props:[
    "isActive"
  ],
  data() {
    return{
        searchKeyword:'',
        hots:[
            {id:1,name:'办公楼'},
            {id:2,name:'写字楼'},
            {id:3,name:'商铺'},
            {id:4,name:'公寓'}
        ]
    }
  },
  mounted(){
    this.searchKeyword=undefined
  },
  methods:{
    back(){
        this.$emit('showActive',false);
    },
    clear(){
        this.searchKeyword=undefined
    },
    searchRes(){
        this.$emit('searchRes',this.searchKeyword,false);
    },
    _hotHref(t){
        this.$emit('searchRes',t.name,false);
    },
    _fillWord(t){
        this.$emit('searchRes',t.name,false);
    }
  }
})
</script>

<style scoped>
.search-container-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 540px;
}
.search-container-wrap {
    top: 0;
    background-color: #fff;
    z-index: 100;
    margin: 0 auto;
}
.search-wrap {
    position: relative;
    padding: 0 50px 0 45px;
    height: 44px;
    border-bottom: 1px solid #DDD;
    font: normal 14px/1.5 Arial,"Lucida Grande",Verdana,"Microsoft Yahei",STXihei,hei;
    color: #000;
    background-color: #e6f0f7;
}
.search-box {
    position: relative;
    z-index: 1;
    padding: 7px 0;
}

.search-box:before {
    content: '';
    display: block;
    position: absolute;
    left: 8px;
    top: 16px;
    z-index: 1;
    width: 8px;
    height: 8px;
    border: 1px solid #A9A9A9;
    border-radius: 50%;
}
.search-box:after {
    content: '';
    display: block;
    position: absolute;
    top: 26px;
    left: 16px;
    z-index: 2;
    width: 6px;
    height: 1px;
    background-color: #A9A9A9;
    -webkit-transform: rotate(40deg);
    -ms-transform: rotate(40deg);
    transform: rotate(40deg);
}
.search-box input {
    position: relative;
    width: 100%;
    padding: 0 32px 0 30px;
    height: 30px;
    font-size: 14px;
    font-family: Arial,"Lucida Grande",Verdana,"Microsoft YaHei",hei;
    background-color: #fff;
    border: 0 none;
    border-radius: 5px;
    outline: 0 none;
    -webkit-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}
.i-clear {
    position: absolute;
    top: 9px;
    right: 0;
    width: 28px;
    height: 28px;
}
.i-clear:before {
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}
.i-clear:after {
    -webkit-transform: rotate(135deg);
    -ms-transform: rotate(135deg);
    transform: rotate(135deg);
}
.i-clear:before, .i-clear:after {
    position: absolute;
    top: 12px;
    left: 6px;
    content: "";
    width: 15px;
    height: 1px;
    background: #999;
}
.search-wrap .s-back, .search-wrap .s-back-active {
    position: absolute;
    top: 0;
    left: 0;
    width: 45px;
    height: 44px;
}
.search-wrap .s-back:after, .search-wrap .s-back-active:after {
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -7px 0 0 -6px;
    content: "";
    width: 12px;
    height: 12px;
    border-left: 2px solid #8A9094;
    border-top: 2px solid #8A9094;
    -webkit-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    transform: rotate(-45deg);
}
.search-wrap .s-btn, .search-wrap .s-btn-active {
    position: absolute;
    top: 0;
    right: 0;
    width: 50px;
    height: 44px;
    padding: 0;
    background: none;
    color: #099fde;
    font-size: 15px;
    font-family: Arial,"Lucida Grande",Verdana,"Microsoft YaHei",hei;
    text-align: center;
    border: 0 none;
}
.search-title {
    margin: 8px 15px 2px;
    font-weight: normal;
    font-size: 13px;
    color: #666;
}
h4 {
    display: block;
    margin-block-start: 1.33em;
    margin-block-end: 1.33em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    font-weight: bold;
}
.search-list {
    position: relative;
    font: normal 16px/1.5 Arial,"Lucida Grande",Verdana,"Microsoft Yahei",STXihei,hei;
    color: #000;
    border-top: 1px solid #DDD;
    background-color: #FFF;
}
.search-list li {
    position: relative;
    padding: 10px 35px;
    border-bottom: 1px solid #DDD;
}
.fill-in, .fill-in-active {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 35px;
}
.fill-in:before, .fill-in-active:before {
    content: "";
    position: absolute;
    top: 16px;
    right: 10px;
    width: 10px;
    height: 9px;
    border-top: 2px solid #CCC;
    border-left: 2px solid #CCC;
}
.fill-in:after, .fill-in-active:after {
    content: "";
    position: absolute;
    top: 22px;
    left: 12px;
    width: 15px;
    height: 2px;
    background-color: #CCC;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
}
</style>
